package com.sz.netty.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.sz.netty.entity.DtuTransportInfo;
import com.sz.netty.mapper.NettyDtuTransportInfoMapper;
import com.sz.netty.service.DtuTransportInfoService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * DTU运输信息服务实现类
 */
@Service
public class NettyDtuTransportInfoServiceImpl extends ServiceImpl<NettyDtuTransportInfoMapper, DtuTransportInfo> implements DtuTransportInfoService {
    
    @Override
    public DtuTransportInfo saveTransportInfo(DtuTransportInfo transportInfo) {
        // 设置创建时间和更新时间
        Date now = new Date();
        if (transportInfo.getCreateTime() == null) {
            transportInfo.setCreateTime(now);
        }
        transportInfo.setUpdateTime(now);
        
        // 设置删除标志默认值
        if (transportInfo.getDelFlag() == null) {
            transportInfo.setDelFlag("F");
        }
        
        // 保存到数据库
        this.save(transportInfo);
        return transportInfo;
    }
    
    @Override
    public DtuTransportInfo getOne(QueryWrapper queryWrapper) {
        return super.getOne(queryWrapper);
    }
    
    @Override
    public List<DtuTransportInfo> list(QueryWrapper queryWrapper) {
        return super.list(queryWrapper);
    }
}